<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <!-- Viewport-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
    <!-- SEO Meta Tags-->
    <meta name="keywords" content="quicky, chat, messenger, conversation, social, communication" />
    <meta name="description" content="Quicky is a Bootstrap based modern and fully responsive Messaging template to help build Messaging or Chat application fast and easy." />
    <meta name="subject" content="communication">
    <meta name="copyright" content="frontendmatters">
    <meta name="revised" content="Sunday, July 18th, 2010, 5:15 pm" />
    <title>{:$configs['SYSTEM_NAME']}</title>
    <!-- Favicon and Touch Icons-->
    <link rel="apple-touch-icon" sizes="180x180" href="./../apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="./../favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="./../favicon-16x16.png">
    <link rel="shortcut icon" href="./../favicon.ico" />
    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="theme-color" content="#ffffff">
    <link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/materialdesignicons.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/bootstrap.min.css">
    <link rel="stylesheet" href="__STATIC__/index/webfonts/inter/inter.css"> 
    <link rel="stylesheet" href="__STATIC__/index/css/app.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/common/cch.css">


    <style type="text/css">
        #chatContactsList {background: url('__STATIC__/index/theme.ff3f4d0f.png');background-position: center;background-size: 60% auto;background-repeat: no-repeat;}
        #initChats {background: url('__STATIC__/index/empty.787e1a1d.png');background-position: center;background-size: 60% auto;background-repeat: no-repeat;}
        #messageBody {background: url('__STATIC__/index/empty.787e1a1d.png');background-position: center;background-size: 60% auto;background-repeat: no-repeat;}

        /*自动换行*/
        .message-content {white-space: pre-line;}

        .table-bordered th {padding: 10px;}
        .table-bordered td {padding:0 10px 0 10px;}
    </style>
</head>

<body class="chats-tab-open">

    <!-- Main Layout Start -->
    <div class="main-layout">
        <!-- Navigation Start -->
        {include file="html/menu" /}
        <!-- Navigation End -->

        <!-- Sidebar Start -->
        {include file="html/session" /}
        <!-- Sidebar End -->

        <!-- Main Start -->
        <main class="main" style="z-index:1021;">

            <!-- Chats Page Start -->
            <div class="chats" id="msgChats" style="display:none;">
                <!-- Chat Body Start -->
                <div class="chat-body">

                    <!-- Chat Header Start-->
                    <div class="chat-header">
                        <!-- Chat Back Button (Visible only in Small Devices) -->
                        <button class="btn btn-secondary btn-icon btn-minimal btn-sm d-xl-none close_btn_mobile" type="button" data-close="" style="margin-right: 10px;">
                            <svg class="hw-20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
                            </svg>
                            <!-- <img class="injectable hw-20" src="./../assets/media/heroicons/outline/arrow-left.svg" alt=""> -->
                        </button>

                        <!-- Chat participant's Name -->
                        <div class="media chat-name align-items-center text-truncate">
                            <div class="avatar text-light d-sm-inline-block mr-3">
                                <span>
                                    <img class="injectable" src="./../assets/media/heroicons/outline/user-group.svg" alt="">
                                </span>
                            </div>

                            <div class="media-body align-self-center ">
                                <h6 class="text-truncate mb-0">AI助理名称</h6>
                                <small class="text-muted" style="display:block;max-width: 180px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;">AI助理描述</small>
                            </div>
                        </div>

                        <!-- Chat Options -->
                        <ul class="nav flex-nowrap">
                            <!-- <li class="nav-item list-inline-item d-none d-sm-block mr-1">
                                <a class="nav-link text-muted px-1" data-toggle="collapse" data-target="#searchCollapse" href="#" aria-expanded="false">
                                    <svg class="hw-20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
                                    </svg>
                                </a>
                            </li> -->

                            <!-- <li class="nav-item list-inline-item d-none d-sm-block mr-1">
                                <a class="nav-link text-muted px-1" href="#" title="Add People">
                                    <svg class="hw-20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>
                                    </svg>
                                </a>
                            </li> -->
                            <li class="nav-item list-inline-item d-none d-sm-block mr-0">
                                <div class="dropdown">
                                    <a class="nav-link text-muted px-1" href="#" role="button" title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        <svg class="hw-20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"/>
                                        </svg>
                                    </a>

                                    <div class="dropdown-menu dropdown-menu-right">
                                        <a class="dropdown-item align-items-center d-flex" href="javascript:void(0)" onclick="closeSession()">
                                        
                                            <svg class="hw-20 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"/>
                                                </svg>
                                              
                                            <span>退出</span>
                                        </a>
                                        <a class="dropdown-item align-items-center d-flex" href="javascript:void(0)" onclick="deleteSession()">
                                            <svg class="hw-20 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
                                              </svg>
                                              
                                            <span>删除</span>
                                        </a>
                                        <a class="dropdown-item align-items-center d-flex text-danger" href="javascript:void(0)" onclick="clearSession()">
                                            <svg class="hw-20 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
                                              </svg>
                                            <span>清空</span>
                                        </a>
                                    </div>
                                </div>
                            </li>
                            <li class="nav-item list-inline-item d-sm-none mr-0">
                                <div class="dropdown">
                                    <a class="nav-link text-muted px-1" href="#" role="button" title="Details" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        <svg class="hw-20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"/>
                                        </svg>
                                    </a>

                                    <div class="dropdown-menu dropdown-menu-right">
                                        <a class="dropdown-item align-items-center d-flex" href="javascript:void(0)" onclick="$('.close_btn_mobile').trigger('click')">
                                        
                                            <svg class="hw-20 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"/>
                                                </svg>
                                              
                                            <span>退出</span>
                                        </a>
                                        <a class="dropdown-item align-items-center d-flex" href="javascript:void(0)" onclick="deleteSessionMobile()">
                                            <svg class="hw-20 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
                                              </svg>
                                              
                                            <span>删除</span>
                                        </a>
                                        <a class="dropdown-item align-items-center d-flex text-danger" href="javascript:void(0)" onclick="clearSession()">
                                            <svg class="hw-20 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
                                              </svg>
                                            <span>清空</span>
                                        </a>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <!-- Chat Header End-->

                    <!-- Search Start -->
                    <div class="collapse border-bottom px-3" id="searchCollapse">
                        <div class="container-xl py-2 px-0 px-md-3">
                            <div class="input-group bg-light ">
                                <input type="text" class="form-control form-control-md border-right-0 bg-transparent pr-0" placeholder="Search...">
                                <div class="input-group-append">
                                    <span class="input-group-text bg-transparent border-left-0">
                                        <svg class="hw-20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
                                          </svg>
                                    </span>
                                </div>
                            </div>
                        </div>
                        
                    </div>
                    <!-- Search End -->

                    <!-- Chat Content Start-->
                    <div class="chat-content p-2" id="messageBody">
                        <div class="container" id="chatContent">

                            <!-- Message Day Start -->
                            <div class="message-day">

                                <div class="message-divider sticky-top pb-2" data-label="Yesterday">&nbsp;</div>

                                <!-- Received Message Start -->
                                <div class="message self">
                                    <div class="message-wrapper">
                                        <div class="message-content">
                                            <span>Wow!  Today is October 30th! Halloween is tomorrow already!  Have you decided what you will be dressing up for Halloween yet, Sara?</span>
                                        </div>
                                    </div>
                                    <div class="message-options">
                                        <div class="avatar avatar-sm"><img alt="" src="./../assets/media/avatar/1.png"></div>
                                        <span class="message-date">9:12am</span>
                                        <div class="dropdown">
                                            <a class="text-muted" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                <!-- Default :: Inline SVG -->
                                                <svg class="hw-18" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z"/>
                                                </svg>
                                            </a>
        
                                            <div class="dropdown-menu">
                                                <a class="dropdown-item d-flex align-items-center" href="#">
                                                    <svg class="hw-18 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"/>
                                                    </svg>
                                                    <span>Copy</span>
                                                </a>
                                                <a class="dropdown-item d-flex align-items-center text-danger" href="#">
                                                    <svg class="hw-18 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
                                                    </svg>
                                                    <span>Delete</span>
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- Received Message End -->

                            </div>
                            <!-- Message Day End -->

                       

                        </div>

                        <!-- Scroll to finish -->
                        <div class="chat-finished" id="chat-finished"></div>
                    </div>
                    <!-- Chat Content End-->


                    <!-- Chat Footer Start-->
                    <div class="chat-footer">
                        <form>
                            <div class="form-row">
                                <!-- Chat Input Group Start -->
                                <div class="col">
                                    <div class="input-group">
                                        <!-- Attachment Start -->
                                        <div class="input-group-prepend mr-sm-2 mr-1">
                                            <div class="dropdown">
                                                <button class="btn btn-secondary btn-icon btn-minimal btn-sm" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                    <svg class="hw-20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v3m0 0v3m0-3h3m-3 0H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"/>
                                                    </svg>
                                                </button>
                                                <div class="dropdown-menu">
                                                    <a class="dropdown-item" href="#" data-toggle="modal" data-target="#createGroup">
                                                        <svg class="hw-20 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"/>
                                                        </svg>
                                                        <span>合同审查</span>
                                                    </a>
                                                    <a class="dropdown-item" href="#" data-toggle="modal" data-target="#aiDraw">
                                                        <svg class="hw-20 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"/>
                                                        </svg>
                                                        <span>AI作画</span>
                                                    </a>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- Attachment End -->
                                
                                        <!-- Emoji Start -->
                                        <div class="input-group-prepend mr-sm-2 mr-1">
                                            <button class="btn btn-secondary btn-icon btn-minimal btn-sm" id="singleOptimizeBtn" type="button" onclick="singleOptimize()" title="优化指令内容">
                                                优
                                            </button>

                                            <button class="btn btn-secondary btn-icon btn-minimal btn-sm" id="loadingOptimizeBtn" type="button" title="指令优化中" style="display: none;">
                                                <div class="spinner-border lyear-loading text-info" style="width: 20px; height: 20px; "></div>
                                            </button>
                                        </div>
                                        <!-- Emoji End -->

                                        <!-- Textarea Start-->
                                        <textarea class="form-control bg-transparent border-0 no-resize hide-scrollbar" id="msg_text" placeholder="请输入你的内容" rows="1"></textarea>
                                        <!-- Textarea End -->
                                    </div>
                                </div>
                                <!-- Chat Input Group End -->
                        
                                <!-- Submit Button Start -->
                                <div class="col-auto">
                                    <div class="btn btn-primary btn-icon rounded-circle text-light mb-1" role="button" onclick="sendMsg()">
                                        <svg class="hw-24" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"/>
                                        </svg>
                                    </div>
                                </div>
                                <!-- Submit Button End-->
                            </div>
                        </form>
                    </div>
                    <!-- Chat Footer End-->
                </div>
                <!-- Chat Body End -->

            </div>
            <!-- Chats Page End -->


            <!-- Chats Page Start -->
            <div class="chats" id="initChats" style="max-width: 100%;position: relative;">
                <div style="width:100%;position: absolute;">
                    <ul class="contacts-list"  data-chat-list="">
                        <?php foreach ($assistants as $k => $vo): ?>
                        <li class="contacts-item init_assistant {:$k==0?'active':''}" data-id="{:$vo['id']}" style="width: 31%;margin:10px 1%;float: left;display: block;">
                            <a class="contacts-link" href="javascript:void(0)">
                                <div class="avatar avatar-online">
                                    <img src="__UPLOAD__/{:$vo['image']}" alt="">
                                </div>
                                <div class="contacts-content">
                                    <div class="contacts-info">
                                        <h6 class="chat-name text-truncate">{:$vo['name']}</h6>
                                    </div>
                                    <div class="contacts-texts">
                                        <p class="text-truncate">{:$vo['description']}</p>
                                    </div>
                                </div>
                            </a>
                        </li>
                        <?php endforeach ?>
                    </ul>
                </div>
                <div style="clear: both;"></div>

                <div class="d-flex flex-column justify-content-center text-center h-100 w-100" >

                    <div class="container">


                        <div class="avatar avatar-lg mb-2">
                            <img class="avatar-img" src="__UPLOAD__/{:$configs['SYSTEM_ICON']}" alt="">
                        </div>

                        <h5>你好，我是{:$configs['SYSTEM_NAME']}！</h5>
                        <p class="text-muted">{:myTextareaShow($configs['SYSTEM_TXT'])}</p>

                        <!-- <button class="btn btn-outline-primary no-box-shadow" type="button" data-toggle="modal" data-target="#startConversation">
                            创建新的对话
                        </button> -->
                        <button class="btn btn-outline-primary no-box-shadow" type="button" onclick="initeCreateSession()">
                            创建新的对话
                        </button>
                    </div>
                </div>
            </div>
            <!-- Chats Page End -->



            <!-- Profile Settings Start -->
            <div class="profile">
                <div class="page-main-heading sticky-top py-2 px-3 mb-3">

                    <!-- Chat Back Button (Visible only in Small Devices) -->
                    <button class="btn btn-secondary btn-icon btn-minimal btn-sm text-muted d-xl-none" type="button" data-close="">
                        <svg class="hw-20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
                          </svg>
                        <!-- <img class="injectable hw-20" src="__STATIC__/index/media/heroicons/outline/arrow-left.svg" alt=""> -->
                    </button>

                    <div class="pl-2 pl-xl-0">
                        <h5 class="font-weight-semibold">设置</h5>
                        <p class="text-muted mb-0">更新个人信息 &amp; 设置</p>
                    </div>
                </div>

                <div class="container-xl px-2 px-sm-3">
                    <div class="row">
                        <div class="col">
                            <div class="card mb-3">
                                <div class="card-header">
                                    <h6 class="mb-1">账号信息</h6>
                                    <p class="mb-0 text-muted small">更新个人信息</p>
                                </div>
                                
                                <div class="card-body">
                                    <form id="profile_form">
                                        <div class="row">
                                            <div class="col-md-6 col-12">
                                                <div class="form-group">
                                                    <label for="nickname">昵称</label>
                                                    <input type="text" class="form-control form-control-md" id="nickname" name="nickname" placeholder="请输入您的昵称" value="">
                                                </div>
                                            </div>

                                            <div class="col-md-6 col-12">
                                                <div class="form-group">
                                                    <label for="truename">姓名</label>
                                                    <input type="text" class="form-control form-control-md" id="truename" name="truename" placeholder="请输入您的姓名" value="">
                                                </div>
                                            </div>
                                         
                                            <div class="col-md-6 col-12">
                                                <div class="form-group">
                                                    <label for="mobile">手机号码</label>
                                                    <input type="text" class="form-control form-control-md" id="mobile" name="mobile" placeholder="请输入您的手机号码" value="" disabled>
                                                </div>
                                            </div>
                                            <div class="col-md-6 col-12">
                                                <div class="form-group">
                                                    <label for="birthday">生日</label>
                                                    <input type="text" class="form-control form-control-md" id="birthday" name="birthday" placeholder="请输入您的生日" value="">
                                                </div>
                                            </div>
                                            <div class="col-md-6 col-12">
                                                <div class="form-group">
                                                    <label for="email">Email</label>
                                                    <input type="email" class="form-control form-control-md" id="email" name="email" placeholder="请输入您的邮箱地址" value="">
                                                </div>
                                            </div>
                                            <div class="col-md-6 col-12">
                                                <div class="form-group">
                                                    <label for="company">公司名称</label>
                                                    <input type="text" class="form-control form-control-md" id="company" name="company" placeholder="请输入您的公司名称" value="">
                                                </div>
                                            </div>
                                            <div class="col-12">
                                                <div class="form-group">
                                                    <label for="signature">个性签名</label>
                                                    <input type="text" class="form-control form-control-md" id="signature" name="signature" placeholder="个性签名" value="">
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>

                                <div class="card-footer d-flex justify-content-end">
                                    <!-- <button type="button" class="btn btn-link text-muted mx-1">Reset</button> -->
                                    <button type="button" class="btn btn-primary profile_btn">保 存</button>
                                </div>
                            </div>

                            <div class="card mb-3">
                                <div class="card-header">
                                    <h6 class="mb-1">密码</h6>
                                    <p class="mb-0 text-muted small">重置密码</p>
                                </div>
                                
                                <div class="card-body">
                                    <form id="pwd_form">
                                        <div class="row">
                                            <div class="col-md-6 col-12">
                                                <div class="form-group">
                                                    <label for="current-password">当前密码</label>
                                                    <input type="password" class="form-control form-control-md" id="current-password" placeholder="Current password" name="old_pwd" autocomplete="on">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="col-md-6 col-12">
                                                <div class="form-group">
                                                    <label for="new-password">新密码</label>
                                                    <input type="password" class="form-control form-control-md" id="new-password" placeholder="New password" autocomplete="off" name="new_pwd">
                                                </div>
                                            </div>
                                            <div class="col-md-6 col-12">
                                                <div class="form-group">
                                                    <label for="repeat-password">确认密码</label>
                                                    <input type="password" class="form-control form-control-md" id="repeat-password" placeholder="Repeat password" autocomplete="off" name="confirm_pwd">
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>

                                <div class="card-footer d-flex justify-content-end">
                                    <!-- <button type="button" class="btn btn-link text-muted mx-1">Reset</button> -->
                                    <button type="button" class="btn btn-primary pwd_btn">保 存</button>
                                </div>
                            </div>

                       
                        </div>
                    </div>
                </div>
            </div>
            <!-- Profile Settings End -->

        </main>
        <!-- Main End -->

        <!-- All Modals Start -->

        {include file="html/modal" /}
        <!-- All Modals End -->
    </div>
    <!-- Main Layout End -->
  

    <!-- Javascript Files -->
    <script src="__STATIC__/index/vendors/jquery/jquery-3.5.0.min.js"></script>
    <script src="__STATIC__/index/vendors/bootstrap/bootstrap.bundle.min.js"></script>
    <script src="__STATIC__/index/vendors/magnific-popup/jquery.magnific-popup.min.js"></script>
    <script src="__STATIC__/index/vendors/svg-inject/svg-inject.min.js"></script>
    <script src="__STATIC__/index/vendors/modal-stepes/modal-steps.min.js"></script>
    <script src="__STATIC__/index/js/app.min.js"></script>
    <script type="text/javascript" src="__STATIC__/admin/js/lyear-loading.js"></script><!-- loading -->

    <script type="text/javascript" src="__STATIC__/common/clipboard.min.js"></script>
    <script src="__STATIC__/common/cch.js"></script>
    <script type="text/javascript" src="__STATIC__/common/cch-util.js"></script>

    <script src="__STATIC__/index/js/session.js"></script>
    <script src="__STATIC__/index/js/msg-options.js"></script>
    <script src="__STATIC__/index/js/htsc.js"></script>
    <script src="__STATIC__/index/js/prompt.js"></script>
    <script src="__STATIC__/index/js/draw.js"></script>
    <script src="__STATIC__/index/js/profile.js"></script>


    <script type="text/javascript">
        const upload_path = '__UPLOAD__';
        const static_path = '__STATIC__';
        const api_path = '/index/';
        var global_assistant = []; // 助理信息
        var global_user = []; // 登录用户信息

        $(function(){
            showUinfo();
            getWaitMsgs(); 
            // getPrompt();
            

            $(".init_assistant").on('click',function(){
                $(".init_assistant").removeClass('active');
                $(this).addClass('active');
            });

            // $(".close_btn_mobile").on('click',function(){
            //     $("#chats-content").addClass('active'); 
            // });
        });





        // 法睿SSE
        function faruiSse(params){
            $.ajax({
                url:'{:url("msg/faruiSse")}',
                type:'post',
                data:params,
                dataType:'json',
                success:function(response){
                    console.log(response);
                    if (response['code'] == 2000) {
                        var reply = response['data']['reply'];
                        if(response['data']['is_finish'] == 1){
                            $("#"+params.uuid).find('.message-content span').html(reply);  
                            scrollBottom();  
                        }else{
                            $("#"+params.uuid).find('.message-content span').html(reply+'...');   
                            scrollBottom();

                            setTimeout(() => {
                                faruiSse(params);
                            }, 500);
                        }
                    }
                },
                error: function(err) {
                    var str = createMsgHtml('AI异常，请重试',1);
                    $("[data-label='"+curdate+"']").parent().append(str);
                    $(".msg_loading").remove();
                    scrollBottom();
                }
            });
        }

        // 发送消息
        function sendMsg(){
            var message = $.trim($("#msg_text").val());
            if (message == null || message == '') {
                cchUtil.message('请输入内容','danger');
                return false;
            }
            var curdate = getFamtterDate();
            if ($("[data-label='"+curdate+"']").length == 0) {
                var str = '<div class="message-day">'+
                            '<div class="message-divider sticky-top pb-2" data-label="'+curdate+'">&nbsp;</div>'+
                        '</div>';
                $("#chatContent").append(str);
            }

            var str = createMsgHtml(message,0);
            $("[data-label='"+curdate+"']").parent().append(str);

            var str = createMsgHtml('AI思考中正在组织语言......',2);
            $("[data-label='"+curdate+"']").parent().append(str);

            $("#msg_text").val('');
            scrollBottom();

            if (global_assistant.request_type == 'HTTP') {
                $.ajax({
                    url:'{:url("msg/chatapi")}',
                    type:'post',
                    data:{session_sn:global_assistant.session_sn,message:message},
                    dataType:'json',
                    success:function(response){
                        var msg_id = '';
                        if (response.code == 2000) {
                            var reply = response.result.data.reply;
                            msg_id = response.result.data.id;
                        }else{
                            var reply = '这个问题太高深了，容我学习深造后再告诉你';
                        }
                        
                        var str = createMsgHtml(reply,1,null,msg_id);
                        $("[data-label='"+curdate+"']").parent().append(str);
                        $(".msg_loading").remove();
                        scrollBottom();
                    },
                    error: function(err) {
                        var str = createMsgHtml('AI异常，请重试',1);
                        $("[data-label='"+curdate+"']").parent().append(str);
                        $(".msg_loading").remove();
                        scrollBottom();
                    }
                });
            }else if (global_assistant.request_type == 'SSE') {
                var uuid = 'msg_'+Math.floor(Math.random() * 100);
                var str = createMsgHtml('...', 1 ,'',uuid);
                $("[data-label='"+curdate+"']").parent().append(str);
                $(".msg_loading").remove();

                var params = {"message":message,session_sn:global_assistant.session_sn};
                var reply = '';
                callBaiduWorkshopSSE('{:url("msg/chatsse")}', params, (msg) => {
                    console.log(msg)
                    if (msg.type == "DATA") {
                        reply = msg.content.result;
                        
                        if (msg.content.is_end) {
                            $("#"+uuid).find('.message-content span').html(reply);
                            // 更新ID
                            $("#"+uuid).attr('id',msg.content.id);
                        }else{
                            $("#"+uuid).find('.message-content span').html(reply+'...');
                        }
                        scrollBottom();
                    } else if (msg.type == "END") {
                        if( message.indexOf("我要找律师") >= 0 || message.indexOf("帮我写一份起诉状") >= 0 || message.indexOf("需要法律援助") >= 0 ) { 
                            reply = '<br /><br />可添加微信详细咨询，微信号：delli1120';
                        } 
                        $("#"+uuid).find('.message-content span').html(reply);
                        
                        console.log("响应返回结束");
                    } else {
                        console.log('-------SSE异常-------');
                        console.log(msg);
                    }
                })
            }
        }

        // 千帆流式接口js调用demo
        function callBaiduWorkshopSSE(url, body, onMessage) {
            // body.stream = true;
            const decoder = new TextDecoder("utf-8");
            let buffer = '';
            let dataMsgBuffer = '';
            const processMessage = (reader) => {
                reader.read().then(content => {
                    if (content.value instanceof ArrayBuffer || ArrayBuffer.isView(content.value)) {
                        buffer += decoder.decode(content.value, {stream: !content.done});
                        const lines = buffer.split('\n');
                        buffer = lines.pop();
                        lines.forEach(line => {
                            if (line == "") { //读取到空行，一个数据块发送完成
                                onMessage({
                                    type: "DATA",
                                    content: JSON.parse(dataMsgBuffer)
                                });
                                dataMsgBuffer = "";
                                return;
                            }
                            let [type] = line.split(":", 1);
                            let content = line.substring(type.length + 1);
                            if (type == 'data') { //数据块没有收到空行之前放入buffer中
                                dataMsgBuffer += content.trim();
                            } else if (type == '' && content != '') { //服务端发送的注释，用于保证链接不断开
                                onMessage({
                                    type: "COMMENT",
                                    content: content.trim()
                                });
                            } else {
                                onMessage({
                                    type: type,
                                    content: content.trim()
                                })
                            }
                        })
                        if (!content.done) {
                            processMessage(reader);
                        } else {
                            onMessage({
                                type: "END"
                            })
                        }
                    }else{
                        onMessage({
                            type: "END"
                        })
                    }
                })
            }
            fetch(url, {
                headers: {
                    "Content-Type": "application/json"
                },
                method: "POST",
                body: JSON.stringify(body)
            })
                .then(response => response.body.getReader())
                .then(reader => processMessage(reader))
                .catch(error => onMessage({
                    type: "ERROR",
                    content: error
                }));
        } 

        

        
        
        


    </script>

</body>

</html>